package com.bigwolf.pe.controller;

import com.bigwolf.pe.domain.entity.SysDept;
import com.bigwolf.pe.domain.entity.SysUser;
import com.bigwolf.pe.domain.vo.TreeSelect;
import com.bigwolf.pe.page.TableDataInfo;
import com.bigwolf.pe.service.ISysDeptService;
import com.bigwolf.pe.service.ISysUserService;
import com.bigwolf.pe.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController {

    @Autowired
    private ISysUserService userService;
    @Autowired
    private ISysDeptService deptService;
    @GetMapping("/list")
    public TableDataInfo list(SysUser user)
    {
        startPage();
        List<SysUser> list = userService.selectUserList(user);
        return getDataTable(list);
    }

    /**
     * 获取部门树列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/deptTree")
    public AjaxResult deptTree(SysDept dept)
    {
        logger.info("===deptTree======");
        List<TreeSelect> lists = deptService.selectDeptTreeList(dept);
        logger.debug("=============="+lists.toString());
        return AjaxResult.success(lists);
    }
}
